package com.java.code.path;

import org.junit.Test;

import java.io.File;

public class Path {
    @Test
    public void getJavaPath() throws Exception {
        //user.dir指定了当前的路径
        System.out.println(System.getProperty("user.dir"));

        //设定为当前文件夹
        File directory = new File("");
        System.out.println(directory.getCanonicalPath());//获取标准的路径
        System.out.println(directory.getAbsolutePath());//获取绝对路径

        //当前文件夹
        File directory1 = new File(".");
        System.out.println(directory1.getCanonicalPath());//获取标准的路径
        System.out.println(directory1.getAbsolutePath());//获取绝对路径

        //上一级目录
        File directory2 = new File("..");
        System.out.println(directory2.getCanonicalPath());//获取标准的路径
        System.out.println(directory2.getAbsolutePath());//获取绝对路径

    }
}
